Passed
Push — master ( 943b8e...9278a4 )
by Mathieu
01:38
created

Quote.getItems   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
1
import {
2
  Entity,
3
  Column,
4
  PrimaryGeneratedColumn,
5
  ManyToOne,
6
  OneToMany
7
} from 'typeorm';
8
import {Customer} from '../Customer/Customer.entity';
9
import {Project} from '../Project/Project.entity';
10
import {User} from '../User/User.entity';
11
import {QuoteItem} from './QuoteItem.entity';
12
13
export enum QuoteStatus {
14
  DRAFT = 'draft',
15
  SENT = 'sent',
16
  REFUSED = 'refused',
17
  ACCEPTED = 'accepted',
18
  CANCELED = 'canceled'
19
}
20
21
@Entity()
22
export class Quote {
23
  @PrimaryGeneratedColumn('uuid')
24
  private id: string;
25
26
  @Column('enum', {enum: QuoteStatus, nullable: false})
27
  private status: QuoteStatus;
28
29
  @Column({type: 'varchar', nullable: false, unique: true})
30
  private quoteId: string;
31
32
  @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'})
33
  private createdAt: Date;
34
35
  @ManyToOne(type => User, {nullable: false})
36
  private owner: User;
37
38
  @ManyToOne(type => Customer, {nullable: false})
39
  private customer: Customer;
40
41
  @ManyToOne(type => Project, {nullable: true})
42
  private project: Project;
43
44
  @OneToMany(
45
    type => QuoteItem,
46
    quoteItem => quoteItem.quote
47
  )
48
  items: QuoteItem[];
49
50
  constructor(
51
    quoteId: string,
52
    status: QuoteStatus,
53
    owner: User,
54
    customer: Customer,
55
    project?: Project | null
56
  ) {
57
    this.quoteId = quoteId;
58
    this.status = status;
59
    this.owner = owner;
60
    this.customer = customer;
61
    this.project = project;
62
  }
63
64
  public getId(): string {
65
    return this.id;
66
  }
67
68
  public getQuoteId(): string {
69
    return this.quoteId;
70
  }
71
72
  public getStatus(): QuoteStatus {
73
    return this.status;
74
  }
75
76
  public getCreatedAt(): Date {
77
    return this.createdAt;
78
  }
79
80
  public getCustomer(): Customer {
81
    return this.customer;
82
  }
83
84
  public getProject(): Project | undefined {
85
    return this.project;
86
  }
87
88
  public getItems(): QuoteItem[] {
89
    return this.items;
90
  }
91
}
92